extends MovingCreature

class_name MovingEnemy

export var speed = 150.0
export var velocity = Vector2(-1, 0)

var dead = false
var armor_type = 100 # The type of monster

func _physics_process(delta):
	var collision_info = move_and_collide(velocity * delta)

	if (collision_info):
		if (collision_info.collider != null):
			if (collision_info.collider is MovingCreature and collision_info.collider.is_player()):
				collision_info.collider.stamina -= 100
		var a = velocity.angle_to(collision_info.normal)
		velocity = - velocity.rotated(2*a)
		move_and_collide(velocity * delta)

	velocity = velocity.normalized() * speed

	if (dead):
		queue_free()

func _ready():
	set_physics_process(true)
